package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.customer.domain.TravelGroupInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.TravelGroupInfo;
import com.ktgj.customer.service.ITravelGroupInfoService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 旅游团产品介绍Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/infos")
public class TravelGroupInfoController extends BaseController
{
    @Autowired
    private ITravelGroupInfoService travelGroupInfoService;

    /**
     * 查询旅游团产品介绍列表
     */
    //@PreAuthorize(hasPermi = "customer:info:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelGroupInfoDto travelGroupInfoDto)
    {
        startPage();
        List<TravelGroupInfoDto> list = travelGroupInfoService.selectTravelGroupInfoList(travelGroupInfoDto);
        return getDataTable(list);
    }

    /**
     * 导出旅游团产品介绍列表
     */
    //@PreAuthorize(hasPermi = "customer:info:export")
    @Log(title = "旅游团产品介绍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelGroupInfoDto travelGroupInfoDto) throws IOException
    {
        List<TravelGroupInfoDto> list = travelGroupInfoService.selectTravelGroupInfoList(travelGroupInfoDto);
        ExcelUtil<TravelGroupInfoDto> util = new ExcelUtil<TravelGroupInfoDto>(TravelGroupInfoDto.class);
        util.exportExcel(response, list, "旅游团产品介绍数据");
    }

    /**
     * 获取旅游团产品介绍详细信息
     */
    //@PreAuthorize(hasPermi = "customer:info:query")
    @GetMapping(value = "/{groupInfoId}")
    public AjaxResult getInfo(@PathVariable("groupInfoId") Long groupInfoId)
    {
        return AjaxResult.success(travelGroupInfoService.selectTravelGroupInfoById(groupInfoId));
    }

    /**
     * 新增旅游团产品介绍
     */
    //@PreAuthorize(hasPermi = "customer:info:add")
    @Log(title = "旅游团产品介绍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelGroupInfoDto travelGroupInfoDto)
    {
        return toAjax(travelGroupInfoService.insertTravelGroupInfo(travelGroupInfoDto));
    }

    /**
     * 修改旅游团产品介绍
     */
    //@PreAuthorize(hasPermi = "customer:info:edit")
    @Log(title = "旅游团产品介绍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelGroupInfoDto travelGroupInfoDto)
    {
        return toAjax(travelGroupInfoService.updateTravelGroupInfo(travelGroupInfoDto));
    }

    /**
     * 删除旅游团产品介绍
     */
    //@PreAuthorize(hasPermi = "customer:info:remove")
    @Log(title = "旅游团产品介绍", businessType = BusinessType.DELETE)
	@DeleteMapping("/{groupInfoIds}")
    public AjaxResult remove(@PathVariable Long[] groupInfoIds)
    {
        return toAjax(travelGroupInfoService.deleteTravelGroupInfoByIds(groupInfoIds));
    }
}
